//
//  ChooseAddressCell.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/2.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "ChooseAddressCell.h"
#import "AddressMainModel.h"

@interface ChooseAddressCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIImageView *lineImgView;
@property (nonatomic, strong) UILabel *nameLab;
@property (nonatomic, strong) UILabel *addressLab;
@property (nonatomic, strong) UILabel *companyLab;

@end

@implementation ChooseAddressCell

+ (instancetype)ChooseAddressCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"ChooseAddressCell";
    ChooseAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ChooseAddressCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = HexColor(0xffffff);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 10, ScreenW - 30, 96)];
        self.bgView.backgroundColor = HexColor(0xFFF7F0);
        [self.contentView addSubview:self.bgView];
        
        self.lineImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 3, self.bgView.nim_height)];
        [self.lineImgView setImage:[UIImage imageNamed:@"icon_address_line"]];
        [self.bgView addSubview:self.lineImgView];
        
        self.nameLab = [[UILabel alloc] initWithFrame:CGRectMake(self.lineImgView.nim_right + 12, 15, self.bgView.nim_width - 10 - (self.lineImgView.nim_right + 12), 17)];
        self.nameLab.textColor = HexColor(0x2B2C44);
        self.nameLab.font = BoldFontOfSize(16);
        [self.bgView addSubview:self.nameLab];
        
        self.addressLab = [[UILabel alloc] initWithFrame:CGRectMake(self.lineImgView.nim_right + 12, 10 + self.nameLab.nim_bottom, self.bgView.nim_width - 10 - (self.lineImgView.nim_right + 12), 15)];
        self.addressLab.textColor = HexColor(0x2B2C44);
        self.addressLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.addressLab];
        
        self.companyLab = [[UILabel alloc] initWithFrame:CGRectMake(self.lineImgView.nim_right + 12, 5 + self.addressLab.nim_bottom, self.bgView.nim_width - 10 - (self.lineImgView.nim_right + 12), 15)];
        self.companyLab.textColor = HexColor(0x2B2C44);
        self.companyLab.font = [UIFont systemFontOfSize:14];
        [self.bgView addSubview:self.companyLab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setModel:(AddressMainModel *)model {
    _model = model;
    [self configUI];
}

- (void)configUI {
    self.nameLab.text = [NSString stringWithFormat:@"%@ %@",self.model.liaison,self.model.tel];
    self.addressLab.text = self.model.address;
    self.companyLab.text = self.model.name;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
